<template>
  <column :options="options" v-model:reduced="columns" />
</template>
<script setup>
import { ref, onMounted } from 'vue'
import column from '@/components/icon-column-select/icon-column-select.vue'
import { useColumns } from './provide-context.js'
import { operationList } from '@/api/log.js'
import { message } from 'ant-design-vue'
let columns = useColumns()
let options = ref([
  {
    title: '操作用户名',
    dataIndex: 'userName',
    key: 'userName',
    fixed: 'left',
    width: 150,
  },
  {
    title: '操作对象',
    dataIndex: 'operationModule',
    key: 'operationModule',
    filters: [],
    filterMultiple: false,
    filteredValue: null,
  },
  {
    title: '进行的操作',
    dataIndex: 'action',
    key: 'action',
  },
  {
    title: '操作时间',
    dataIndex: 'createTime',
    key: 'createTime',
    width: 180,
  },
  {
    title: '操作',
    dataIndex: 'operation',
    key: 'operation',
    fixed: 'right',
    width: 100,
  },
])
//初始化调用
onMounted(async () => {
  try {
    let res = await operationList()
    if (res.data) {
      columns.value.forEach(e => {
        if (e.key === 'operationModule') {
          e.filters = res.data
        }
      })
    }
  } catch (e) {
    message.error('获取操作对象列表失败')
  }
})
</script>
